const db=uniCloud.database()

async function friendLoadMore({
	friend_uid
} = {}) {
	let whereObj = {
		user_id: this.current_uid
	}

	if (friend_uid) {
		Object.assign(whereObj,{friend_uid:friend_uid})
	}
	
	
	
	let resFriend=await db.collection('uni-im-friend').where(whereObj).get()
	
	if (resFriend.data.length===0){
		return {
			errCode: 0,
			errMsg: 'success',
			data: resFriend.data
		}
	}else{
		let res = await db.collection(
				db.collection('uni-im-friend').where(whereObj).field('friend_uid,mark,class_name')
				.getTemp(),
				db.collection('uni-id-users').field('_id,nickname,avatar_file').getTemp()
			)
			.limit(500)
			.get()
		
		return {
			errCode: 0,
			errMsg: 'success',
			data: res.data
		}
	}
	
	
}

module.exports = {
	friendLoadMore
}